<template>
	<xn-form-container title="模板预览" :width="1000" v-model:open="visible" :destroy-on-close="true" @close="onClose">
		<xn-file-preview :src="src" :file-type="fileType" @goBack="onClose" />
	</xn-form-container>
</template>

<script setup name="filePreview">
	import fileApi from '@/api/dev/fileApi'
	const src = ref()
	const fileType = ref()
	const visible = ref(false)
	const emit = defineEmits({ goBack: null })
	// 打开
	const onOpen = (record) => {
		visible.value = true
		// 查询文件详情
		const param = {
			urlList: new Array(record.content)
		}
		fileApi.fileGetFileListByUrlList(param).then((data) => {
			src.value = data[0].downloadPath
			fileType.value = data[0].suffix
		})
	}
	// 关闭
	const onClose = () => {
		visible.value = false
		src.value = ''
	}
	defineExpose({
		onOpen
	})
</script>
